<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #tu{
            position: absolute;
            top: -500px;
            left: -500px;
        }
    </style>
</head>
<body>
    <img id="tu" src="https://iknow-base.cdn.bcebos.com/623MINGXING270x170x2.jpg">
    <script>
        var tu=document.getElementById("tu");
        window.onmousemove=function(e){
            var event=e||window.event;
          var x= event.clientX;
          var y=event.clientY;
          console.log(x,y)
          if(x<10||x>document.body.clientWidth-tu.offsetWidth){
              x=-800;
          }
          if(y<10){
              y=-800;
          }
          tu.style.top=y+"px";
          tu.style.left=x+"px";

        }
    </script>
</body>
</html>